load("@rules_proto//proto:defs.bzl", "proto_library")
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
    name = "kvnemesis",
    srcs = [
        "applier.go",
        "doc.go",
        "engine.go",
        "env.go",
        "generator.go",
        "kvnemesis.go",
        "operations.go",
        "seq_tracker.go",
        "validator.go",
        "watcher.go",
    ],
    embed = [":kvnemesis_go_proto"],
    importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvnemesis",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/config/zonepb",
        "//pkg/keys",
        "//pkg/kv",
        "//pkg/kv/kvclient/kvcoord",
        "//pkg/kv/kvnemesis/kvnemesisutil",
        "//pkg/kv/kvpb",
        "//pkg/kv/kvserver",
        "//pkg/kv/kvserver/concurrency/isolation",
        "//pkg/kv/kvserver/concurrency/lock",
        "//pkg/kv/kvserver/liveness",
        "//pkg/roachpb",
        "//pkg/settings/cluster",
        "//pkg/sql/catalog/bootstrap",
        "//pkg/storage",
        "//pkg/storage/enginepb",
        "//pkg/testutils/datapathutils",
        "//pkg/util/bufalloc",
        "//pkg/util/ctxgroup",
        "//pkg/util/encoding",
        "//pkg/util/hlc",
        "//pkg/util/log",
        "//pkg/util/protoutil",
        "//pkg/util/retry",
        "//pkg/util/span",
        "//pkg/util/syncutil",
        "//pkg/util/timeutil",
        "//pkg/util/tracing",
        "//pkg/util/tracing/tracingpb",
        "@com_github_cockroachdb_cockroach_go_v2//crdb",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_cockroachdb_pebble//:pebble",
        "@com_github_cockroachdb_pebble//vfs",
        "@org_golang_google_protobuf//proto",
    ],
)

go_test(
    name = "kvnemesis_test",
    size = "medium",
    srcs = [
        "applier_test.go",
        "engine_test.go",
        "generator_test.go",
        "kvnemesis_test.go",
        "main_test.go",
        "operations_test.go",
        "validator_test.go",
    ],
    data = glob(["testdata/**"]),
    embed = [":kvnemesis"],
    exec_properties = {"test.Pool": "heavy"},
    deps = [
        "//pkg/base",
        "//pkg/config/zonepb",
        "//pkg/kv",
        "//pkg/kv/kvclient/kvcoord",
        "//pkg/kv/kvnemesis/kvnemesisutil",
        "//pkg/kv/kvpb",
        "//pkg/kv/kvserver",
        "//pkg/kv/kvserver/apply",
        "//pkg/kv/kvserver/concurrency/isolation",
        "//pkg/kv/kvserver/kvserverbase",
        "//pkg/kv/kvserver/kvserverpb",
        "//pkg/roachpb",
        "//pkg/security/securityassets",
        "//pkg/security/securitytest",
        "//pkg/server",
        "//pkg/settings/cluster",
        "//pkg/storage",
        "//pkg/storage/enginepb",
        "//pkg/testutils/datapathutils",
        "//pkg/testutils/echotest",
        "//pkg/testutils/serverutils",
        "//pkg/testutils/skip",
        "//pkg/testutils/sqlutils",
        "//pkg/testutils/testcluster",
        "//pkg/util/buildutil",
        "//pkg/util/envutil",
        "//pkg/util/hlc",
        "//pkg/util/leaktest",
        "//pkg/util/log",
        "//pkg/util/randutil",
        "//pkg/util/syncutil",
        "//pkg/util/uuid",
        "@com_github_cockroachdb_errors//:errors",
        "@com_github_stretchr_testify//assert",
        "@com_github_stretchr_testify//require",
        "@org_golang_google_protobuf//proto",
    ],
)

proto_library(
    name = "kvnemesis_proto",
    srcs = ["operations.proto"],
    strip_import_prefix = "/pkg",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/kv/kvpb:kvpb_proto",
        "//pkg/kv/kvserver/concurrency/isolation:isolation_proto",
        "//pkg/roachpb:roachpb_proto",
        "//pkg/util/hlc:hlc_proto",
        "@com_github_cockroachdb_errors//errorspb:errorspb_proto",
        "@com_github_gogo_protobuf//gogoproto:gogo_proto",
    ],
)

go_proto_library(
    name = "kvnemesis_go_proto",
    compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"],
    importpath = "github.com/cockroachdb/cockroach/pkg/kv/kvnemesis",
    proto = ":kvnemesis_proto",
    visibility = ["//visibility:public"],
    deps = [
        "//pkg/kv/kvpb",
        "//pkg/kv/kvserver/concurrency/isolation",
        "//pkg/roachpb",
        "//pkg/util/hlc",
        "@com_github_cockroachdb_errors//errorspb",
        "@com_github_gogo_protobuf//gogoproto",
    ],
)
